package com.example.event;


import cn.hutool.core.lang.UUID;
import com.example.dto.UserCouponDTO;
import org.springframework.stereotype.Component;

import java.util.Date;

import static com.example.constant.MqConstants.Exchange.PROMOTION_TOPIC;
import static com.example.constant.MqConstants.Key.COUPON_RECEIVE;

/**
 * @Author: jia-qiang ljq1024.cc
 * @desc: 发送用户领取优惠券的MQ消息
 * @Date: 2024-05-20-20:54
 */
@Component
public class UserReceiveCouponMessageEvent extends BaseEvent<UserCouponDTO> {


    private String topic = PROMOTION_TOPIC;

    private String routingKey = COUPON_RECEIVE;
    @Override
    public EventMessage<UserCouponDTO> buildEventMessage(UserCouponDTO data) {
        return EventMessage.<UserCouponDTO>builder().data(data)
                .id(String.valueOf(UUID.randomUUID().toString(true)))
                .timestamp(new Date())
                .build()
                ;
    }

    @Override
    public String topic() {
        return topic;
    }

    @Override
    public String routingKey() {
        return  routingKey;
    }
}
